package com.rw.pay.controller;


import com.feign.RentInfoFeign;
import com.rw.common.entity.OrderInfo;
import com.rw.common.entity.RentInfo;
import com.rw.pay.service.OrderInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器：定义增删改查功能
 * </p>
 *
 * @author Rabit
 * @since 2021-12-20
 */
@RestController
@RequestMapping("/common/orderInfo")
public class OrderInfoController {
    Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private OrderInfoService orderInfoService;

    @Autowired
    private RentInfoFeign rentInfoFeign;

    @GetMapping("{id}")
    public OrderInfo getOrderInfoById(@PathVariable("id") Integer id){
        logger.error("orderInfo的getOrderInfoById被调用了==={}",id);
        return orderInfoService.getById(id);
    }

    @PostMapping("save")
    public OrderInfo save(OrderInfo orderInfo){
        boolean flag = orderInfoService.save(orderInfo);
       return flag?orderInfo:null;
    }

    @GetMapping("rent/{id}")
    public RentInfo getOrderToRentById(@PathVariable("id") Integer id){
        logger.error("通过orderInfo的getOrderToRentById去调用RentInfo的数据==={}",id);
        return rentInfoFeign.getOrderInfoById(id);
    }

    @PostMapping("rent/save")
    public RentInfo getOrderToRentById(RentInfo rentInfo){
        logger.error("保存的数据==={}",rentInfo);
        return rentInfoFeign.save(rentInfo);
    }




}

